package com.jjsc.client.api.factory;

import com.jjsc.client.api.RemoteUserAddressService;
import com.jjsc.client.api.domain.UserAddress;
import com.jjsc.common.core.domain.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * @Author: 钟城明
 * @CreateTime: 2025-11-04
 * @Description:
 * @Version: 1.0
 */
@Slf4j
public class RemoteUserAddressFallbackFactory implements FallbackFactory<RemoteUserAddressService> {

    @Override
    public RemoteUserAddressService create(Throwable cause) {

        log.error("用户地址服务调用失败:{}", cause.getMessage());

        return new RemoteUserAddressService() {
            @Override
            public R<UserAddress> getUserAddress(Long id, String source) {
                return R.fail("获取用户地址失败：" + cause.getMessage());
            }
        };
    }
}
